﻿using Uber.Core;

namespace Uber.Service
{
    using System;
    using Core.Model;
    using Core.Repository;
    using Core.Service;

    public class PayRequests : IPayRequests
    {
        private readonly IPayRequestRepo repo;
        private readonly IAccounts accounts;

        public PayRequests(IPayRequestRepo repo, IAccounts accounts)
        {
            this.repo = repo;
            this.accounts = accounts;
        }

        public string Insert(int amount, string login, string email, string role)
        {
            //var accountId = accounts.GetId(login);
            //var gold = accounts.GetGold(accountId);
            //if (gold < 200) return "not enough credits";    
            //return repo.Insert(amount, DateTime.Now, accountId, email, Tools.ToTip(role));
            return "";
        }

        

        public IPageable<PayRequest> GetPage(int page, int pageSize)
        {
            return new Pageable<PayRequest>
                       {
                           PageIndex = page,
                           Page = repo.GetPage(pageSize, page, null, null),
                           PageCount = ServiceUtils.GetPageCount(pageSize, repo.GetCount(null, null))
                       };
        }

        public IPageable<PayRequest> GetPageByPlayer(int page, int pageSize, string pro)
        {
            //var proId = accounts.GetId(pro);
            //return new Pageable<PayRequest>
            //{
            //    PageIndex = page,
            //    Page = repo.GetPage(page, pageSize, null, proId),
            //    PageCount = ServiceUtils.GetPageCount(pageSize, repo.GetCount(null, proId))
            //};

            return null;
        }
    }
}